import { reqBaseCategoryList, reqBannerList, reqFloorList } from '@/api';

const state = {
    //三级分类列表
    categoryList: [],
    banner: [],
    floors: []
}
const mutations = {
    RECEIVE_BASE_CATEGORY_LIST(state, list) {
        state.categoryList = list
    },
    RECEIVE_BANNER(state, data) {
        state.banner = data
    },
    RECEIVE_FLOORS(state, data) {
        state.floors = data
    }
}
const actions = {
    // 获取商品三级分类列表
    async getBsaeCategoryList({ commit }) {
        const data = await reqBaseCategoryList();
        if (data.code === 200) {
            commit('RECEIVE_BASE_CATEGORY_LIST', data.data)
        }
    },
    //首页轮播图
    async getBanner({ commit }) {
        const { data } = await reqBannerList()
        if (data.code === 200) {
            commit('RECEIVE_BANNER', data.data)
        }
    },
    //首页楼层
    async getFloors({ commit }) {
        const { data } = await reqFloorList()
        if (data.code === 200) {
            commit('RECEIVE_FLOORS', data.data)
        }
    }
}
const getters = {}

export default {
    state,
    mutations,
    actions,
    getters
}